<?php

class Bootstrap extends YouNet_Bootstrap
{

	protected function _initAutoload()
	{
		Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH . '/modules/Core/controllers/helpers/', 'Core_Controller_Helper_');
	}
	
	public function __initPaymentManager()
	{
		parent::__initPaymentManager();

		$manager = Payment_Manager::getInstance();
		$manager->setOptions($this->getOptions());
		$manager->registerHandler(new Payment_Item_Trial());
		$manager->registerHandler(new Payment_Item_Campaign());
		$manager->registerHandler(new Payment_Item_Footer());
	}

	public function __initPath()
	{
		// Define path to image directory
		define('IMG_PATH', STATIC_PATH . '/img');

		// Define path to image directory
		define('UPLOAD_PATH', STATIC_PATH . '/media/image');
		define('UPLOAD_URL', STATIC_URL . '/media/image');

		// Define path to image directory
		define('SKIN_PATH', INDEX_PATH . '/media/skin');
        define('TEMPLATE_PATH', SKIN_PATH . '/template');

		define('THUMBNAIL_PATH', UPLOAD_PATH . DIRECTORY_SEPARATOR . FOLDER_THUMBNAIL);
		define('BANNER_PATH', UPLOAD_PATH . DIRECTORY_SEPARATOR . FOLDER_BANNER);
		define('BACKGROUND_PATH', UPLOAD_PATH . DIRECTORY_SEPARATOR . FOLDER_BACKGROUND);
		define('WELCOME_PATH', UPLOAD_PATH . DIRECTORY_SEPARATOR . FOLDER_WELCOME);
        define('SHARE_PATH', UPLOAD_PATH . DIRECTORY_SEPARATOR . FOLDER_SHARE);

		define('THUMBNAIL_URL', UPLOAD_URL . DIRECTORY_SEPARATOR . FOLDER_THUMBNAIL);
        
        $bitlyConfig = $this->getOption('bitly');
		if( $bitlyConfig )
		{
			define('BITLY_HOST', $bitlyConfig['host']);
			define('BITLY_USERNAME', $bitlyConfig['username']);
			define('BITLY_API_KEY', $bitlyConfig['apiKey']);
		}
		
		$recaptchaConfig = $this->getOption('recaptcha');
		if( $recaptchaConfig )
		{
			define('RECAPTCHA_PUBLIC_KEY', $recaptchaConfig['publickey']);
			define('RECAPTCHA_PRIVATE_KEY', $recaptchaConfig['privatekey']);
		}
		
		$arrFile	= array();
		$language	= 'en';
		$locale		= 'en_US';
		if ($this->getOption('appSwitchToVideo'))
		{
			define('APP_INSTANCE', APP_INSTANCE_VIDEO);
			define('APPLICATION_NAME', 'Video Contest');
			define('APPLICATION_DESCRIPTION', 'Video Contest');
			define('DEFAULT_TITLE','Video Contest');
			define('DEFAULT_IMAGE','default_banner_video.png');
			define('DEFAULT_IMAGE_THUMB','default_banner_thumb_video.png');
			define('DEFAULT_WELCOME_IMAGE','fangate-logo-video.png');
			$arrFile[]		= APPLICATION_PATH.'/languages/'.$language.'/main-video.csv';
			$arrFile[]		= APPLICATION_PATH.'/modules/Core/languages/'.$language.'/main-video.csv';
			$arrFile[]		= APPLICATION_PATH.'/modules/Tab/languages/'.$locale.'/main-video.csv';
		}
		else
		{
			define('APP_INSTANCE', APP_INSTANCE_IMAGE);
			define('APPLICATION_NAME', 'Photo Contest');
			define('APPLICATION_DESCRIPTION', 'Photo Contest');
			define('DEFAULT_TITLE','Photo Contest');
			define('DEFAULT_IMAGE','default_banner_image.png');
			define('DEFAULT_IMAGE_THUMB','default_banner_thumb_image.png');
			define('DEFAULT_WELCOME_IMAGE','fangate-logo-image.png');
			$arrFile[]		= APPLICATION_PATH.'/languages/'.$language.'/main-image.csv';
			$arrFile[]		= APPLICATION_PATH.'/modules/Core/languages/'.$language.'/main-image.csv';
			$arrFile[]		= APPLICATION_PATH.'/modules/Tab/languages/'.$locale.'/main-image.csv';
		}
		$translate	= Zend_Registry::get('Zend_Translate'); 
		foreach($arrFile as $file)
		{
			if( file_exists($file) )
			{
				$translate->addTranslation(
					array(
						'adapter'		=> 'csv', 
						'content'		=> $file,
						'locale'		=> 'en',
						'delimiter'		=> ';'
					)
				);
			}
		}
	}
	
	protected function _initTimezone()
    {
    	date_default_timezone_set('GMT');
    }

    protected function _initLocale()
    {
        Zend_Registry::getInstance()->set('Zend_Locale', LOCALE_DEFAULT);
    }
}
